package android.tusnotas.changes;

import android.content.Context;
import android.content.res.Resources;
import android.tusnotas.beans.Course;
import android.tusnotas.beans.PushNotification;

public class PushChange implements Change{

	private Resources res;
	private PushNotification notification;
	private Course course;

	public PushChange() {
		super();
	}

	public PushChange(Context context, PushNotification notification, Course course) {
		super();
		this.res = context.getResources();
		this.notification = notification;
		this.course = course;
	}


	@Override
	public String getBarTitle() {
		if(res.getConfiguration().locale.getLanguage().equalsIgnoreCase("en")){
			return "Webcampus notification";
		} else {
			return "Notificación de Webcampus";
		}
	}

	@Override
	public String getTitle() {
		if(res.getConfiguration().locale.getLanguage().equalsIgnoreCase("en")){
			return "Webcampus notification";
		} else {
			return "Notificación de Webcampus";
		}

	}

	public Integer getInstanceId(){
		return course.getInstanceId();
	} 

	public Integer getCourseId(){
		return course.getId();
	}

	@Override
	public String getContent(){
		if(res.getConfiguration().locale.getLanguage().equalsIgnoreCase("en")){
			return getEnglishContent();
		}else{
			return getSpanishContent();
		}
	};

	private String getEnglishContent() {
		try {
			return notification.getEnglishDescription(course.getName());
		} catch (Exception e) {
			e.printStackTrace();
			return "New notification";
		}
	}

	private String getSpanishContent() {
		try {
			return notification.getSpanishDescription(course.getName());
		} catch (Exception e) {
			e.printStackTrace();
			return "Nueva notificación";
		}
	}



}
